package routing

import (
	"github.com/labstack/echo/v4"
	"law_case_api/controller"
)

// NotAuthRoute 路由
func NotAuthRoute(e *echo.Group) *echo.Group {
	e.POST("/login", controller.Login)
	e.POST("/logout", controller.Login)
	e.POST("/file/upload", controller.UploadFile)
	e.GET("/file/get", controller.GetFileInfo)
	e.GET("/select/list", controller.GetSelectList)
	return e
}

// AuthRoute 路由
func AuthRoute(e *echo.Group) *echo.Group {
	customerGroup(e)
	contractGroup(e)
	caseGroup(e)
	dataGroup(e)
	systemGroup(e)
	return e
}

// 客户路由
func customerGroup(e *echo.Group) {
	g := e.Group("/customer")
	g.POST("/create", controller.CreateCustomer)
	g.POST("/list", controller.GetCustomerList)
	g.GET("/get", controller.GetCustomerInfo)
	g.GET("/select", controller.GetCustomerSelect)
	//客户事项记录
	g.POST("/event/create", controller.CreateCustomerEvent)
	g.GET("/event/list", controller.GetCustomerEventList)
	g.GET("/event/del", controller.GetCustomerEventList) //todo
	//客户附件管理
	g.POST("/accessory/create", controller.CreateCustomerAccessory)
	g.GET("/accessory/list", controller.GetCustomerAccessoryList)
	g.GET("/accessory/del", controller.GetCustomerAccessoryList) //todo
	//客户联系人管理
	g.POST("/contact/create", controller.CreateCustomerContact)
	g.GET("/contact/list", controller.GetCustomerContactList)
	g.GET("/contact/del", controller.GetCustomerContactList) //todo
}

// 合同路由
func contractGroup(e *echo.Group) {
	g := e.Group("/contract")
	g.POST("/create", controller.CreateContract)
	g.POST("/list", controller.ContractList)
	g.GET("/get", controller.GetContractInfo)
	g.POST("/update_status", controller.JudgeContract)
	g.GET("/select", controller.GetCustomerContractSelect)

	//合同事项记录
	g.POST("/event/create", controller.CreateContractEvent)
	g.GET("/event/list", controller.GetContractEventList)
	g.GET("/event/del", controller.GetContractEventList) //todo
	//合同附件管理
	g.POST("/accessory/create", controller.CreateContractAccessory)
	g.GET("/accessory/list", controller.GetContractAccessoryList)
	g.GET("/accessory/del", controller.GetContractAccessoryList) //todo
}

// 案件路由
func caseGroup(e *echo.Group) {
	g := e.Group("/case")
	g.POST("/create", controller.CreateCase)
	g.POST("/list", controller.CaseList)
	g.POST("/export", controller.ExportCase)
	g.GET("/get", controller.GetCaseInfo)

	//案件任务
	g.POST("/task/create", controller.CreateCaseTask)
	g.POST("/task/list", controller.CaseTaskList)
	g.GET("/task/get", controller.GetCaseTaskInfo)
	g.GET("/task/del", nil) // todo

	//案件费用
	g.POST("/cost/create", controller.CreateCaseCost)
	g.POST("/cost/list", controller.CaseCostList)
	g.GET("/cost/get", nil) //todo
	g.GET("/cost/del", nil) //todo

	//案件文档
	g.POST("/doc/create", controller.CreateCaseDoc)
	g.POST("/doc/list", controller.CaseDocList)
	g.GET("/doc/get", nil) //todo
	g.GET("/doc/del", nil) //todo

	//案件日志
	g.POST("/log/create", controller.CreateCaseLog)
	g.POST("/log/list", controller.CaseLogList)
	g.GET("/log/get", nil) //todo
	g.GET("/log/del", nil) //todo

	//案件进度
	g.POST("/schedule/create", controller.CreateCaseSchedule)
	g.POST("/schedule/list", controller.CaseScheduleList)
	g.GET("/schedule/get", nil) //todo
	g.GET("/schedule/del", nil) //todo
}

// 案件路由
func dataGroup(e *echo.Group) {
	g := e.Group("/data")
	g.GET("/get", controller.GetDashboardData)
	g.GET("/case", controller.GetDashboardCaseData)
	g.GET("/e-chart/case-step-data", controller.GetCaseStepEchartsData)
}

// 系统路由
func systemGroup(e *echo.Group) {
	g := e.Group("/system")
	g.GET("/route/list", controller.RouteList)
	g.GET("/role/list", controller.RoleList)
	g.POST("/role_route/update", controller.UpdateRoleRoute)
}
